<header>
    <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="brand" href="/amazone/index.php">Amazone</a>
          <div class="nav-collapse collapse">
              <ul class="nav actions">
                  <li class="divider-vertical"></li>
                  <?php 
                    // si le user est connecté, affichage de ses infos dans la navbar
                  
                    $pathCourant=  dirname($_SERVER["PHP_SELF"]); 
                    $pathAdmin = $pathCourant == "/amazone/admin" ? '../' : '';
                    
                    if(isset($_SESSION['user'])){
                        $user = unserialize($_SESSION['user']);
                        
                        
                        echo "<li class='divider-vertical'></li>";
                        echo "<li><a href='".$pathAdmin."profil.php' > ".$user->getPrenom()." ".$user->getNom()."</a></li>";
                        echo "<li class='divider-vertical'></li>";
                        if($user->estAdmin()){
                                $chemin = $pathAdmin == ''? 'admin/index.php' : 'index.php'; 
                            echo "<li><a href = '$chemin'>Admin</a></li>";
                            echo "<li class='divider-vertical'></li>";
                        }
                        echo "<li><a href='".$pathAdmin."deco.php'>Se déconnecter</a></li>";
                        echo "<li class='divider-vertical'></li>";
                        $nbArticles = $user->getPanier()->getNbProduitsPanier();
                        echo "<li><a href='#' class='btnShowModalPanier'>Panier($nbArticles)</a></li>";
                    }
                    else{
                        echo "<li><a id='connexion_modal'>Connexion</a></li>";
                        echo "<li class='divider-vertical'></li>";
                        echo "<li><a id='sinscrire_modal'>S'inscrire</a></li>";
                        echo "<li class='divider-vertical'></li>";
                        // si un user anonyme possède un panier, affichag du nb de produit
                        if(isset($_SESSION['userAnonyme'])){
                            $user = unserialize($_SESSION['userAnonyme']);
                            $nbArticles = $user->getPanier()->getNbProduitsPanier();
                        }
                        else{
                            $nbArticles = 0;
                        }
                        echo "<li><a href='#' class='btnShowModalPanier'>Panier($nbArticles)</a></li>";
                        echo "<li class='divider-vertical'></li>";
                    }
                  ?>
              </ul>
          </div>
          
        </div>
      </div>
    </div>
</header>